package com.ftg.shopping.carshop.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ftg.shopping.carshop.entity.orderdetails;
import com.ftg.shopping.carshop.entity.sp_cartshop;
import com.ftg.shopping.carshop.entity.sp_orderinfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


import java.util.List;
import java.util.Map;

@Mapper
public interface carshopMapper extends BaseMapper<sp_cartshop> {
    @Select("select photourl,goodsname,goodsoutprice,count,sum from sp_cartshop where userid=#{userid}")
    List<Map<String,Object>> showcar(String userid);

    @Insert("insert into sp_cartshop(id,photourl,userid,goodsname,goodsoutprice,count,sum) values (#{id},#{photourl},#{userid},#{goodsname},#{goodsoutprice},#{count},#{sum})")
    int insertcar(sp_cartshop spc);

    @Delete("delete from sp_cartshop where goodsname=#{goodsname} and userid=#{userid}")
    int deletecar(String goodsname,String userid);

    @Delete("delete from sp_cartshop where id in#{ids}")
    int deletecars(List<Integer> ids);

    @Insert("insert into sp_orderinfo (orderid,username,money,address,phone) values(#{orderid},#{username},#{money},#{address},#{phone})")
    int insertorder(int orderid,String username,String money,String address,String phone);

    @Insert("insert into orderdetails(orderid,goodsname) values(#{orderid},#{goodsname})")
    int insertordertetails(int orderid,String goodsname);


}
